package com.neusoft.lohas.modules.ivm.entity.business;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.common.collect.Lists;
import com.neusoft.lohas.common.persistence.IdEntity;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;
/**
 * 商圈最新优惠类(功能为热点图片形式)
 * @author jackie.liu
 * @version 2015-01-29
 */
@Entity
@Table(name = "ivm_business_concession")
@DynamicInsert
@DynamicUpdate
public class Concession extends IdEntity<Concession> {

	private static final long serialVersionUID = 1L;
	private Merchant merchant; // 商户信息
	private String logoUrl; //图片地址
	private String status; //排序号
	
	private List<ConcessionPhoto> photoList = Lists.newArrayList(); // 热点图片列表
	
	public Concession() {
		super();
	}

	public Concession(String id) {
		this();
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="merchant_id")
	@NotFound(action = NotFoundAction.IGNORE)
	@JsonIgnore
	@NotNull(message="所属商户信息不能为空")
	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public String getLogoUrl() {
		return logoUrl;
	}

	public void setLogoUrl(String logoUrl) {
		this.logoUrl = logoUrl;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	@OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "concession")
	@Where(clause="del_flag='"+DEL_FLAG_NORMAL+"'")
	@OrderBy("create_date")
	@NotFound(action = NotFoundAction.IGNORE)
	public List<ConcessionPhoto> getPhotoList() {
		return photoList;
	}

	public void setPhotoList(List<ConcessionPhoto> photoList) {
		this.photoList = photoList;
	}
	
}
